import Vue from 'vue'

global.level = '';

Vue.filter('getLocalTime', function(nS,arg1) {
	if(nS != null && nS != ''){
		//月日时分秒为单位时前面补零
		function fillZero(v) {
			if (v < 10) {
				v = '0' + v;
			}
			return v;
		}
		var Y,M,D,H,I,S;
		var d = new Date(parseInt(nS / 1000) * 1000);
		var Week = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
		Y = d.getFullYear();
		M = fillZero(d.getMonth() + 1);
		D = fillZero(d.getDate());
		H = fillZero(d.getHours());
		I = fillZero(d.getMinutes());
		S = fillZero(d.getSeconds());

		if (arg1 == 1) {//getSimpleTime
			var simpleTime = Y + '/' + M + '/' + D;
			return simpleTime;
		}else{
			var localTime = Y + '/' + M + '/' + D + ' ' + H + ':' + I + ':' + S;
			return localTime;
		}
		
	}
})

Vue.filter('limitSize', function(arg) {
	if(arg.length > 20) {
		var size = arg.substring(0, 20) + '...';
		return size;
	} else {
		return arg;
	}
});

Vue.filter('changeZero', function(target, arg, count) {
	if (arg != 1) {
		if (arg == 3) return count > 0 ? target : '-';
		return '-';
	}
	return target;
});
